// 用户自定义 检查配置内容
//

#include <iostream>
#include "str_util.h"
#include "check.h"


using namespace std;
using namespace su;

#undef REG
#define REG(fun) STATIC_RUN( CheckMgr::Ins().Reg(#fun, fun);) 

#define GET(t,field) \
				const t* p##field = row.Get<  std::remove_pointer<decltype(p##field)>::type >(#field);\
				L_COND_V(p##field);\
				const t& field = *p##field;\

#define GET_F(t,field) \
				const t* p##field = row->Get<  std::remove_pointer<decltype(p##field)>::type >(#field);\
				L_COND_F(p##field);\
				const t& field = *p##field;\

namespace
{
	//例子
	bool PlayerSheet1(const Sheet& sheet)
	{
		bool bOk = true;
		set<uint32> setid;
		//遍历sheet例子
		sheet.EachRow([&](const RowInfo& row)
			{
				GET(uint32, id);
				LDEBUG("id=%d", id);
				if (!(setid.insert(id).second))
				{
					bOk = false;
					LERROR("PlayerSheet1 id repeated. %d", id);
				}
				GET(string, str0);
				LDEBUG("str0=%s", str0.c_str());
				GET(string, str1);
				LDEBUG("str1=%s", str1.c_str());
				GET(double, doubleNum);
				LDEBUG("doubleNum=%0.3f", doubleNum);
			});

		{	//查找指定sheet，id例子
			const Sheet* p2 = CheckMgr::Ins().GetSheet("PlayerSheet2");
			L_COND_F(p2);
			const RowInfo* row = p2->FindRow(2);
			L_COND_F(row);
			GET_F(double, d);
			LDEBUG("PlayerSheet2 d=%0.1f", d);
		}
		return bOk;
	}
	//REG(PlayerSheet1) //注册检查函数，不通项目自己定义
}


